﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PublicController.cs" company="Spenta Consulting">
//   (c) Copyright 2011
// </copyright>
// <summary>
//   MVC controller for anonymous users
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Spenta.StreetCare.MVC.Controllers
{
    using System.Linq;
    using System.Web.Mvc;
    using Spenta.StreetCare.MVC.Models;

    /// <summary>
    /// MVC controller for anonymous users
    /// </summary>
    public class PublicController : BaseController
    {
        /// <summary>
        /// Maps this instance.
        /// GET: /Public/Map
        /// </summary>
        /// <returns>The map view</returns>
        public ActionResult Map()
        {
            if (Entities.Categories.Any(c => c.CategoryCustomerID == this.Customer.CustomerID) && Entities.Status.Any(s => s.StatusCustomerID == this.Customer.CustomerID))
            {
                // We allow the user to browse the map only if there is at least one category and one status
                return View(new MapModel { Customer = this.Customer });
            }

            return RedirectToAction("EditCurrent", "Customer");
        }

        /// <summary>
        /// Signins this instance.
        /// GET: /Public/Map
        /// </summary>
        /// <returns>The signin</returns>
        public ActionResult Signin()
        {
            return View();
        }
    }
}
